<title>登录系统</title>
<style>
input{
    margin: 20px;
}
form{
    border-radius: 10px;
}
</style>
<div>
<h1>欢迎使用登录系统</h1>
<form>
    <label for="sn">学号是</label>
    <input type="text" name="" value="" id="sn">
    <label for="pswd">密码是</label>
    <input type="password" name="" value="" id="pswd">
    <input onclick="login()" value="登录" type="button"></input>
    <input type="reset"></input>
</form>
</div>
<div id="userinfo">

</div>
<script>
    function login() {
        let sn = document.getElementById("sn").value;
        let pswd = document.getElementById("pswd").value;
        alert("你在登录，学号是："+sn+"密码是："+pswd);
        fetch("/yzdl?sn="+sn+"&pswd="+pswd)
        .then(resp => resp.json())
        .then(date =>{
            if (date == null){
                alert("登录失败");
            }else {
                
                localStorage.setItem("user",JSON.stringify(date));
                document.getElementById("userinfo").innerText = "欢迎您：" + date.Name + "性别是："+date.Sex+"学号是："+date.Sn+"年级是："+date.Grade
                window.location.href = "/"
            }
        })
    }
</script>